﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SC.eWedding.BusinessLogic.Views;
using SC.eWedding.BusinessLogic.Handlers;

public partial class Proveedor_EdicionProveedor : System.Web.UI.Page
{
    #region Propiedades Privadas

    private int Modo
    {
        get { return int.Parse(Request.QueryString["modo"]); }
    }

    private int NumberSelected
    {
        get
        {
            if (Request.QueryString["selectedItem"] != null)
                return int.Parse(Request.QueryString["selectedItem"]);
            else
                return 0;
        }
    }

    private ProveedorView SelectedItem
    {
        get
        {
            if (Session["ProveedorView"] == null)
            {
                if (NumberSelected == 0)
                    Session["ProveedorView"] = new ProveedorView();
                else
                    Session["ProveedorView"] = ProveedorHandler.FindById(NumberSelected);
            }

            return (ProveedorView)Session["ProveedorView"];
        }
        set { Session["ProveedorView"] = value; }
    }

    #endregion

    #region  Private Methods

    private void CleanSession()
    {
        Session.Remove("ProveedorView");
    }

    private void CargarProveedor()
    {
        veProveedor.CargarProveedor();
    }

    #endregion

    #region  Events

    protected void Page_Load(object sender, EventArgs e)
    {       
        if (!IsPostBack)
        {
            veProveedor.CargarCombos();
            //CleanSession();
            CargarProveedor();
        }
    }

    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        veProveedor.Guardar();

        //Redireccionar a la pagina principal
    }

    #endregion
}
